Crate empfindung
source ·Expand description
Empfindung
Empfindung is a library providing implementations of colour difference algorithms. Specifically, distances based on L*a*b* colour space often referred to as ΔE. (This is also where the package gets its name. The ‘E’ stands for German ‘Empfindung’).
The crate provides CIEDE2000 (in cie00
module), CIE94 (in cie94
),
CIE76 (in cie76
module) and CMC l:c (in cmc
module) implementations.
Example
use empfindung::cie00;
use empfindung::cie76;
let colour_1 = lab::Lab { l: 38.972, a: 58.991, b: 37.138 };
let colour_2 = lab::Lab { l: 54.528, a: 42.416, b: 54.497 };
let delta_e = cie00::diff(colour_1, colour_2);
println!("The CIEDE2000 colour difference is: {}", delta_e);
assert_eq!(20.553642, delta_e);
let colour_1 = (38.972, 58.991, 37.138);
let colour_2 = (54.528, 42.416, 54.497);
let delta_e = cie76::diff(colour_1, colour_2);
println!("The Euclidean distance is: {}", delta_e);
assert_eq!(28.601656, delta_e);
let colour_1 = rgb::RGB::<u8>::new(234, 76, 76);
let colour_2 = rgb::RGB::<u8>::new(76, 187, 234);
let delta_e = cie00::diff(colour_1, colour_2);
println!("The CIEDE200 colour difference is: {}", delta_e);
assert_eq!(58.90164, delta_e);
Crate Features
The crate defines lab
and rgb
features which are enabled by default.
With both of them enabled, create provides ToLab
implementation for
rgb::RGB<u8>
type which means that diff
functions can be used with
rgb::RGB<u8>
arguments.
Furthermore, if lab
enabled the diff
functions can accept lab::Lab
argument and diff_rgb
functions as well as DE2000
is provided. Note
that the latter two are a deprecated features.
Re-exports
pub use cie00::DE2000;